# file name: app/network_monitor/agent/base_monitor_agent.py
from abc import ABC, abstractmethod
from datetime import datetime
from typing import Optional, Dict, Any
from dataclasses import dataclass


@dataclass
class MonitorResult:
    """Dataclass representing the result of a monitoring operation.
    
    Attributes:
        target_id: Unique identifier for the monitored target
        status: Current status (UP/DOWN/DEGRADED)
        metrics: Dictionary of collected metrics
        timestamp: When the monitoring occurred
        error: Optional error message if monitoring failed
    """
    target_id: str
    status: str
    metrics: Dict[str, Any]
    timestamp: datetime
    error: Optional[str] = None


class BaseMonitorAgent(ABC):
    """Abstract base class for all monitoring agents.
    
    Provides the interface for monitoring operations and configuration.
    """

    @abstractmethod
    def monitor(self) -> MonitorResult:
        """Execute the monitoring operation.
        
        Returns:
            MonitorResult: Result of the monitoring operation
        """
        pass

    @abstractmethod
    def get_target_type(self) -> str:
        """Get the type of target being monitored.
        
        Returns:
            str: Type identifier for the monitoring target
        """
        pass

    @abstractmethod
    def configure(self, config: Dict) -> None:
        """Apply configuration to the monitoring agent.
        
        Args:
            config: Dictionary containing configuration parameters
        """
        pass